import ajax from '@/utils/ajax'

export type TMethod = 'get' | 'post' | 'put' | 'delete' | 'patch'

export default {
    login(data: object) {
        return ajax('/login', {
            method: 'post',
            data,
        })
    },
    getLeaveCountApi() {
        return ajax('/leave/count')
    },
    getMenuListApi(params: object) {
        return ajax('/menus', { data: params })
    },
    getUserListApi(params?: object) {
        return ajax('/users', { data: params })
    },
    delUserApi(userIds: number[]) {
        return ajax('/users', {
            method: 'delete',
            data: {
                userIds,
            },
        })
    },
    postAddUser(user: object, method: TMethod = 'post') {
        return ajax('/users', {
            method,
            data: user,
        })
    },
    menuOper(data: object, type: TMethod) {
        return ajax('/menus', {
            method: type,
            data,
        })
    },
    getRolesApi() {
        return ajax('/roles', {}, true)
    },
    getRolesListApi() {
        return ajax('/roles/list')
    },
    roleApi(data: object, method: TMethod) {
        return ajax('/roles', {
            method,
            data,
        })
    },
    deptApi(data: object, method: TMethod) {
        return ajax('/depts', {
            data,
            method,
        })
    },
}
